package com.flower8.service.impl;

import com.flower8.dao.BankDao;
import com.flower8.model.Bank;
import com.flower8.service.BankService;
import com.flower8.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description:
 * @Author: tanglin
 * @Date: 2019/10/18 17:13
 * @Version: 1.0
 */
@Service
public class BankServiceImpl implements BankService {

    @Autowired
    private BankDao bankDao;

    /**
     * 查询银行列表
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<Bank> getBankList(PageData pd) throws Exception {
        return bankDao.getBankList(pd);
    }

    /**
     * 查询银行列表数量
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getBankListCount(PageData pd) throws Exception {
        return bankDao.getBankListCount(pd);
    }

    /**
     * 根据银行卡id查询
     * @param pd
     * @return
     */
    @Override
    public Bank getBankById(PageData pd) throws Exception {
        return bankDao.getBankById(pd);
    }

    /**
     * 更新银行
     * @param bank
     * @throws Exception
     */
    @Override
    @Transactional
    public void updateBank(Bank bank) throws Exception {
        bankDao.updateBank(bank);
    }

    /**
     * 删除银行
     * @param id
     * @throws Exception
     */
    @Override
    @Transactional
    public void deleteBank(long id) throws Exception {
        bankDao.deleteBank(id);
    }

    /**
     * 新增银行
     * @param bank
     * @throws Exception
     */
    @Override
    @Transactional
    public void addBank(Bank bank) throws Exception {
        bankDao.addBank(bank);
    }

    /**
     * 查询所有银行
     * @throws Exception
     */
    @Override
    public List<Bank> getAllBank() throws Exception {
        return bankDao.getAllBank();
    }
}
